﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using PairingMatrix.Common.Enum;

namespace PairingMatrix.Model
{
    public class AbsenteesModel : BusinessModelBase
    {
        public ObservableCollection<TeamMemberModel> TeamMemberModels { get; set;}

        public AbsenteesModel()
        {
            TeamMemberModels = new ObservableCollection<TeamMemberModel>();
        }
        public void AddTeamMember(TeamMemberModel teamMember)
        {
            var existing = TeamMemberModels.FirstOrDefault(t => t.Id == teamMember.Id);
            if (existing != null)
                TeamMemberModels.Remove(existing);

            TeamMemberModels.Add(teamMember);
            teamMember.Wall = WallType.AbsenteesWall;
        }


        public void RemoveTeamMember(TeamMemberModel teamMember)
        {
            var teamMemberModel = TeamMemberModels.FirstOrDefault(t => t.Id == teamMember.Id);
            if(teamMemberModel != null)
                TeamMemberModels.Remove(teamMember);
        }
    }
}